<?php

require_once 'Zend/View/Helper/Abstract.php';

class Core_View_Helper_Filesystem_RenderMenuBrowser extends Zend_View_Helper_Abstract
{
    public function renderMenuBrowser($parentId, $basePath = null, $id = 'menuTree')
    {
        $menu = new Model_Menu();

        $children = $menu->getMenuItems($parentId, true);

        foreach ($children as $child) {
            $label = $child->title;

            if (!empty($child->label)) {
                $label =  $child->label . ' / ' . $label;
            }

            $class = 'menu';
            $submenu = $this->view->renderMenuBrowser($child->id, $link);

            $linkId = Core_Toolbox_String::addUnderscores($menu->path, true);
            $links[] = '<li class="menuItem"><a href="/admin/navigation/open/id/' . $child->id . '" class="' . $class . '" id="page-' . $child->id . '">' . $label . '</a>' . $submenu . '</li>';
        }

        if (is_array($links)) {
            if ($level == 0) {
                $strId = 'id="' . $id . '"';
            }
            return  '<ul ' . $strId . '>' . implode(null, $links) . '</ul>';
        }
    }
}